package com.example.springbootdemo.entity;

import lombok.Data;
import lombok.ToString;
import org.dromara.easyes.annotation.IndexField;
import org.dromara.easyes.annotation.IndexName;
import org.dromara.easyes.annotation.InnerIndexField;
import org.dromara.easyes.annotation.MultiIndexField;
import org.dromara.easyes.annotation.rely.Analyzer;
import org.dromara.easyes.annotation.rely.FieldStrategy;
import org.dromara.easyes.annotation.rely.FieldType;

/**
 * @ClassName: Document
 * @Description:
 * @Author: TXW
 * @Date: 2024-02-01
 */

@Data
@IndexName
@ToString
public class EsContent {
    /**
     * es中的唯一id
     */
    private String id;
    /**
     * 文档标题
     */
    private String title;
    /**
     * 文档内容
     */
    private String content;

    //es中不存在的字段
    @IndexField(exist = false)
    private String notExistsField;

    //字段为空时更新
    @IndexField(strategy = FieldStrategy.NOT_EMPTY)
    private String creator;

    //指定字段类型
    @IndexField(fieldType = FieldType.TEXT, fieldData = true)
    private String fileData;

    //重命名字段名称
    @IndexField("rename-fields")
    private String renameField;

    //支持日期格式化
    @IndexField(fieldType = FieldType.DATE,dateFormat = "yyyy-mm-dd HH:mm:ss")
    private String fmDate;

    //指定分词器
    @IndexField(fieldType = FieldType.TEXT, analyzer = Analyzer.IK_SMART)
    private String checkWords;

    //不区分大小写
    @IndexField(fieldType = FieldType.KEYWORD,ignoreCase = true)
    private String caseTest;

    /**
     * 复合字段,此注解和SpringData中的MultiField用法类似 适用于对同一个字段通过多种分词器检索的场景
     */
    @MultiIndexField(mainIndexField = @IndexField(fieldType = FieldType.KEYWORD),
            otherIndexFields = {@InnerIndexField(suffix = "zh", fieldType = FieldType.TEXT, analyzer = Analyzer.IK_SMART),
                    @InnerIndexField(suffix = "pinyin", fieldType = FieldType.TEXT, analyzer = Analyzer.PINYIN)})
    private String multiField;


}
